<%--
  Created by IntelliJ IDEA.
  User: Ken
  Date: 2022/4/15
  Time: 9:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生列表</title>
</head>
<body>
    <h1>学生列表</h1>

    <button onclick="javascript:location.href='studentinsertquery'">新增学生</button>

    <table border="1">
        <tr>
            <th><input type="checkbox"/>全选</th>
            <th>学生编号</th>
            <th>学生姓名</th>
            <th>学生性别</th>
            <th>所属班级</th>
        </tr>

        <c:forEach items="${page.datas}" var="stu">
            <tr>
                <td><input type="checkbox"/></td>
                <td>${stu.id}</td>
                <td>${stu.name}</td>
                <td>${stu.sex == 1 ? '男' : '女'}</td>
                <td>${stu.classes.className}(${stu.classes.classCount})</td>
            </tr>
        </c:forEach>
    </table>

    <!-- 分页导航 -->
    <c:if test="${page.page == 1}">
        <a href="#">首页</a>
        <a href="#">上一页</a>
    </c:if>
    <c:if test="${page.page > 1}">
        <a href="stuquerypage?page=1&pageSize=3">首页</a>
        <a href="stuquerypage?page=${page.page - 1}&pageSize=3">上一页</a>
    </c:if>

    <!-- 展示导航页码 -->
    <c:forEach items="${page.index}" var="i">
        <c:if test="${i == page.page}">
            <a>${i}</a>
        </c:if>
        <c:if test="${i != page.page}">
            <a href="stuquerypage?page=${i}&pageSize=3">${i}</a>
        </c:if>
    </c:forEach>

    <c:if test="${page.page == page.pageCount}">
        <a href="#">下一页</a>
        <a href="#">尾页</a>
    </c:if>
    <c:if test="${page.page < page.pageCount}">
        <a href="stuquerypage?page=${page.page + 1}&pageSize=3">下一页</a>
        <a href="stuquerypage?page=${page.pageCount}&pageSize=3">尾页</a>
    </c:if>

    第${page.page}页/共${page.pageCount}页
</body>
</html>
